import { Module } from "vuex";
import { RootState } from "../utils/store.type";

interface UmmannedAgriculturalState {
	ummannedAgriculturalData: Array<{
		nestid: string;
		message: any[];
	}>;
}

const ummannedAgriculturalStatus: Module<UmmannedAgriculturalState, RootState> = {
	namespaced: true,
	state: () => ({
		ummannedAgriculturalData: [],
	}),

	mutations: {
		updateUmmannedAgriculturalData(state, payload): void {
			let isHave = state.ummannedAgriculturalData.find(item => {
				return item.nestid === payload.nestid
			})
			if (isHave) {
				isHave = payload
			} else {
				state.ummannedAgriculturalData.push(payload)
			}
		}
	},

};

export default ummannedAgriculturalStatus;
